﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using Framework.GameObjectManagment.GameObjects;
using Framework.Graphics;

namespace Framework.GameObjectManagment
{
    public class GameObjectManager
    {
        private List<GameObject> _gameObjects;

        public List<GameObject> GameObjects
        {
            get { return _gameObjects; }
            set { _gameObjects = value; }
        }    
        
        public void Init()
        {
            _gameObjects = new List<GameObject>();
            _gameObjects.Add(new Player());
            _gameObjects.Add(new Enemy());
        }

        public void LoadContent(ContentManager content)
        {
            for (int i = 0; i < _gameObjects.Count; i++)
            {
                _gameObjects[i].LoadContent(content);
            }
        }

        public void Update()
        {
            for (int i = 0; i < _gameObjects.Count; i++)
            {
                _gameObjects[i].Update();
            }
        }

        public void DrawShadowObjects(Framework.Graphics.Light.LightArea LA)
        {
            Camera.SpriteBatch.Begin();
            for (int i = 0; i < _gameObjects.Count; i++)
            {
                if (_gameObjects[i].CastShadows == true)
                {
                    _gameObjects[i].DrawShadows(LA);
                }
            }
            Camera.SpriteBatch.End();
        }

        public void Draw()
        {
            Camera.SpriteBatch.Begin();
            for (int i = 0; i < _gameObjects.Count; i++)
            {
                _gameObjects[i].Draw();
            }
            Camera.SpriteBatch.End();
        }
    }
}
